package top.mcwebsite.playandroid.business.search.impl.vm

import androidx.paging.PagingData
import kotlinx.coroutines.flow.Flow
import top.mcwebsite.playandroid.business.search.impl.model.HotSearchKey
import top.mcwebsite.playandroid.business.search.impl.model.SearchHistoryData
import top.mcwebsite.playandroid.business.search.impl.model.SearchHistoryKey
import top.mcwebsite.playandroid.business.search.impl.model.SearchResultModel
import top.mcwebsite.playandroid.lib.mvi.base.IIntent
import top.mcwebsite.playandroid.lib.mvi.base.IUiEffect
import top.mcwebsite.playandroid.lib.mvi.base.IUiState
import top.mcwebsite.playandroid.lib.mvi.model.Async


data class SearchUiState(
    val searchKeyword: String = "",
    val hotSearchKeys: Async<List<HotSearchKey>> = Async.UnInitialization,
    val searchHistoryData: List<SearchHistoryKey> = emptyList(),
    val searchResultPagerFlow: Flow<PagingData<SearchResultModel>>? = null
) : IUiState

sealed interface SearchIntent : IIntent {
    data class UpdateSearchKeywordIntent(val keyword: String) : SearchIntent

    data object SearchActionIntent : SearchIntent

    data class SearchResultItemClickIntent(val searchResultModel: SearchResultModel): SearchIntent

}

sealed interface SearchUiEffect : IUiEffect {
    data class GoDetailPageUiEffect(val searchResultModel: SearchResultModel): SearchUiEffect

}